'use strict';

const findOrCreate = require('../lib/mongoose/plugin_findorcreate');

module.exports = mongoose => {
  const SpaceAppSchema = new mongoose.Schema({
    space: { type: mongoose.Schema.Types.ObjectId, ref: 'Space' },
    app: { type: mongoose.Schema.Types.ObjectId, ref: 'App' },
    config: { type: Object },
  });

  SpaceAppSchema.plugin(findOrCreate);

  return mongoose.model('SpaceApp', SpaceAppSchema);
};
